#include<cstdio>
#include<iostream>
using namespace std;
int T,n,a[20];
int dfs(int pos,int last_red,int last_blue,int sum){
    if(pos==n+1) return sum;
    int red,blue;
    if(last_red==a[pos]) red=dfs(pos+1,a[pos],last_blue,sum+a[pos]);
    else red=dfs(pos+1,a[pos],last_blue,sum);//now == red
    if(last_blue==a[pos]) blue=dfs(pos+1,last_red,a[pos],sum+a[pos]);
    else blue=dfs(pos+1,last_red,a[pos],sum);//now == blue
    return max(red,blue);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        cout<<dfs(1,0,0,0)<<'\n';
    }
    return 0;
}
